package com.pestano.aula2;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

import android.app.Activity;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.CompoundButton;
import android.widget.CompoundButton.OnCheckedChangeListener;
import android.widget.EditText;
import android.widget.Spinner;
import android.widget.Toast;

public class Main extends Activity {
	/** Called when the activity is first created. */


	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.main);
		
	}


	@Override
	protected void onPause() {
		// TODO Auto-generated method stub
		super.onPause();
	}


	@Override
	protected void onResume() {
		// TODO Auto-generated method stub
		super.onResume();
	}



	public void cadastrarClick(View v){
		startActivityForResult(new Intent(getBaseContext(), CrudActivity.class), 123);
	}
	
	public void editarClick(View v){
		Intent it = new Intent(getBaseContext(), Edit.class);
		EditText editText = (EditText) findViewById(R.id.editText1);
		if(!ValidacaoUtil.isPreenchido(editText,"Preencha o campo id")){
			return;
		}
		it.putExtra("codigo", editText.getText().toString());
		startActivity(it);
		
	}

	public void listarClick(View v){
		startActivity(new Intent(getBaseContext(), Listar.class));
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		 if(resultCode == RESULT_OK){
			 if(requestCode == 123){//vindo da tela de cadastro
				 Toast.makeText(getBaseContext(), "Produto "+data.getStringExtra("nome") +" cadastrado com sucesso!", Toast.LENGTH_LONG);
				 
			 }
			 
		 }
		 
		 
	}
 
	public void listarSQLite(View v){
		startActivity(new Intent(getBaseContext(), ClienteActivity.class));
	}
	
}